package com.leenleda.ips.receiver;

import com.leenleda.ips.util.FileUtils;

import java.io.File;

public class Constant {

    public static final String AUTO_TIME_READ = "auto_time_read";

    public static boolean DIALOG_IS_SHOW = false;

    public static final String CURRENT_SYSTEM_TIME = "now_time";
    public static final String DEVICE_OPEN_TIME = "device_open_time";
    public static final String SCROLL_BEAN = "scroll_bean";

    public static boolean NET_STATE = true;
    public static final String CRASH_TAG = "crash_tag";
    public static final String CONNECT_TAG = "connect_tag";
    public static final String ANDROID_ID = "android_id";
    public static boolean APP_RESTART = true;
//    public static String VIDEO_CACHE = "video_cache";
    public static final int AUTHOR_TIME = 10;//授权使用次数

    public static int cacheSize = 500;
    public static String voiceSpeed = "40";
    public static String voiceRdn = "";
    public static final String VOICE_SPEED = "voice_speed";
    public static final String VOICE_RDN = "voice_rdn";
    public static final String CACHE_FOLDER = "9527";

    public static final String SERVICE = "com.leld.updatetool.serve.CoreService";//启动跟新工具服务
    public static final String TIMER_LOOP_ACTION = "com.leenleda.ips.receiver.Loop";
    public static final String SWITCH_PLAY = "com.leld.updatetool.switch.play";
    public static final int REFRESH_JS = 101;
    public static final int SHOW_TOAST = 102;
    public static final int REFRESH_LOOP = 1111;
    public static final int REFRESH_DOWNLOAD = 2222;




    public static final String SET_INPUT_IP = "set_input_ip";//输入还未经认证的服务器ip
    public static final String PUBLISH_URL = "publish_url";//发布的url
    public static final String PUBLISH_TYPE = "publish_type";//发布的type
    public static final String DEVICE_REGISTER = "device_register";//设备是否认证
    public static final String PUBLISH_DATA = "publish_data";//发布的内容
    public static final String PUBLISH_BASE = "publish_base";//基础信息
    public static final String PUBLISH_IP = "ipServer";//服务器ip
    public static final String PUBLISH_FILE_IP = "ipServer.txt";//服务器ip文件
    public static final String PUBLISH_FILE_MAC = "deviceMac.txt";
    public static final String PUBLISH_FILE_BASE = "deviceInfo.txt";//基础信息文件
    public static final String PUBLISH_FILE_DATA = "data.txt";//发布内容文件
    public static final String PUBLISH_FILE_LOG = "log.txt";//基础信息文件


    public static final int SET_SNAP_PIC = 6666;
    public static final int PUSH_MSG = 5555;
    public static final int KILL_SELF = 7777;
    public static final int SET_SERVICE_IP = 1001;
    public static final int SET_MEDIA_DATA = 1002;
    public static final int REFRESH_WEB = 1003;
    public static final int UPDATE_APPLICATION = 1004;
    public static final int SET_VOICE_SPEED = 1005;
    public static final int SET_CACHE_SIZE = 1006;
    public static final int CLEAR_ALL_CACHE = 1007;
    public static final int AUTO_TIME = 1008;
    public static final int INTERNET_CHANGE = 2001;
    public static final int DEVICE_PERMISSION_FALSE = 3001;
    public static final int DEVICE_PERMISSION_TRUE = 3002;
    public static final int PUSH_ROLL_MSG = 3004;
    public static final int MISS_ROLL_MSG = 3005;
    public static final int PUSH_INSERT_MSG = 3006;
    public static final int MISS_INSERT_MSG = 3007;
    public static final int RELOAD_OPEN_TIME = 3008;
    public static final int LIVE_SEEK_NEXT = 3009;
    public static final String DEVICE_PERMISSION_STATE = "permission_state";
    public static final String RECEIVE_FORM_SERVICE = "com.leld.updatetool.Controller";//更新工具发送给MAIN APP的通知


    public static final String RECEIVE_FORM_LELDIPS = "com.leenleda.ips.app";//信发发送给更新工具通知在线APP
    public static final String RECEIVE_FORM_LELDIPS_UPDATE = "com.leenleda.ips.app.update";
    public static final String APP_PACKAGE_NAME = "com.leenleda.ips";



    /**
     * webview刷新状态(默认为开启刷新)
     */
    public static final String WebViewRefreshStatus = "RefreshStatus";
    public static final String WEB_LOAD_END = "web_load_end";//webView最后一次加载
    public static final String WEB_LOAD_GET = "web_load_get";//设备认证返回
    public static final String WEB_LOAD_TIME = "web_load_time";//设备认证的时间
    public static int REFRESH_TIME = 5;



    public static boolean APP_TEST = false;

    public static final String URL_BASIC = "file:///android_asset/url/";
    public static final String STATIC_URL_TEST = URL_BASIC + "systemctl.html";
    public static final String STATIC_URL_BLANK = URL_BASIC + "blank.html";

    public static final String RES_TITLE = "res_title";





    public static final boolean ANTI_ALIAS = true;

    public static final int DEFAULT_SIZE = 150;
    public static final int DEFAULT_START_ANGLE = 270;
    public static final int DEFAULT_SWEEP_ANGLE = 360;

    public static final int DEFAULT_ANIM_TIME = 1000;

    public static final int DEFAULT_MAX_VALUE = 100;
    public static final int DEFAULT_VALUE = 50;

    public static final int DEFAULT_HINT_SIZE = 15;
    public static final int DEFAULT_UNIT_SIZE = 30;
    public static final int DEFAULT_VALUE_SIZE = 15;

    public static final int DEFAULT_ARC_WIDTH = 15;

    public static final int DEFAULT_WAVE_HEIGHT = 40;


    public static int toAim = 1;



    public static final int DEVICE_AUTO_TIME = 10001;
    public static final int DEVICE_DOWN = 10002;
    public static final int DEVICE_RESTART = 10003;
    public static final int DEVICE_REOPEN = 10004;
    public static final int DEVICE_VOICE_SET = 10005;
    public static final int DEVICE_VOICE_CHANGE = 10006;
    public static final int DEVICE_LAMP = 10011;

    public static int SHOW_TIME_LOOP = 0;



    public static final String PUBLISH_WEB = "WebUrl";
    public static final String PUBLISH_SOURCE = "Source";
    public static final String PUBLISH_LIVE = "live";
    public static final String LOAD_STATIC_URL = "load_static_url";


    /**
     * 删除文件
     *
     * @param fileName
     * @return
     */
    public static boolean deleteFile(String fileName) {
        boolean status;
        SecurityManager checker = new SecurityManager();
//        File file = new File(FILE_PATH + fileName);
        File file = new File(FileUtils.getPath(Constant.CACHE_FOLDER) + fileName);
        if (file.exists()){
            checker.checkDelete(file.toString());
            if (file.isFile()) {
                try {
                    file.delete();
                    status = true;
                } catch (SecurityException se) {
                    se.printStackTrace();
                    status = false;
                }
            } else
                status = false;
        }else
            status = false;
        return status;
    }
}
